﻿@model FCDB.Entity.FormCDB
@using FB.Extensions;
@{
    ViewBag.Title = "财务打印";
    Layout = "~/Views/Shared/_FormLayout.cshtml";
    var IsViewMode = Model.Status != (short)FCDB.Entity.FormStatusEnum.Empty && Model.Status != (short)FCDB.Entity.FormStatusEnum.Draft;

}
@section HeadIncluder
{
    <link href='@Url.Content("~/Content/public.css")' rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")' rel="stylesheet" />
}
<div class="f_btn">
    <div class="f_btnc">
        <button type="button" onclick="Print()" class="fj btn_c3 btn_s">打印</button>
        <button type="button" onclick="Close()" class="fj btn_c3 btn_s">关闭</button>

    </div>
</div>
<div class="frombox" id="formMain">
    <div class="from_l" style="background: #fff;">
        <div class="left_con_f PrintArea">

            <div align="center" class="left_f_tit">财务打印</div>
            @using (Html.BeginForm("SaveFinance", "Form", FormMethod.Post, new { id = "frm" }))
            {
                <input type="hidden" name="ProcessGuid" value='@Request["ProcessGuid"]' />
                <input type="hidden" name="ID" value="@Model.ID" />
                <input type="hidden" name="FormGuid" value="@Model.FormGuid" />
                <input type="hidden" name="Status" value="@Model.Status" />
                Html.RenderPartial("UCHiddenArea");
                <table width="100%" class="left_xx">
                    <tr>
                        <td class="text_w" align="center">
                            流程名称：
                        </td>
                        <td colspan="5">
                            @if (IsViewMode)
                            {
                                @Model.FormTitle
                            }
                            else
                            {
                                <input id="txtFormTitle" style="width:98%;" class="validate[required] in_c1 " type="text" name="FormTitle" value="@Model.FormTitle" />
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="text_w" align="center">
                           审批序号：
                        </td>
                        <td colspan="5">
                                @Model.AppInstanceID
                        </td>
                    </tr>
                    <tr>
                        <td @(Model.InvoiceType == null || Model.InvoiceType == 0 ? "rowspan=3" : "rowspan=2") class="text_w" align="center">04.出纳确认收款信息</td>
                        <td class="text_w" align="center">财务实收金额</td>
                        <td colspan="2">

                            <input type="text" id="financiaAmount" name="financiaAmount" class=" in_c1 validate[custom[number]] " style="width:98%" value="@Model.financiaAmount" />

                        </td>
                        <td class="text_w" align="center">收费日期</td>
                        <td colspan="2">
                            <input type="text" id="ChargingDate" name="ChargingDate" class="in_c1 " style="width:98%" value="@Model.ChargingDate" />

                        </td>
                    </tr>
                    @if (Model.InvoiceType == null || Model.InvoiceType == 0)
                    {
                        <tr>
                            <td class="text_w" align="center">收据开具情况</td>
                            <td colspan="2">
                                <select id="ReceiptInfo" name="ReceiptInfo" class="validate[required] in_c1" style="width:90%   ">
                                    <option @(Model.ReceiptInfo == "" ? "selected" : "") value=""></option>
                                    <option @(Model.ReceiptInfo == "未开收据" ? "selected" : "") value="未开收据">未开收据</option>
                                    <option @(Model.ReceiptInfo == "收据已开，款已收" ? "selected" : "") value="收据已开，款已收">收据已开，款已收</option>
                                    <option @(Model.ReceiptInfo == "收据已开，款未收" ? "selected" : "") value="收据已开，款未收">收据已开，款未收</option>
                                </select>

                            </td>

                        </tr>
                    }
                    <tr>
                        <td class="text_w" align="center">出纳备注</td>
                        <td colspan="5">

                            <input type="text" id="FinanceRemark" name="FinanceRemark" class=" in_c1 " style="width:98%" value="@Model.FinanceRemark" />
                        </td>

                    </tr>
                    <tr>
                        <td rowspan="6" class="text_w" align="center" style="width:129px">05.业务员填写返佣信息</td>
                        <td colspan="1" class="text_w" align="center">公司名称</td>
                        <td colspan="5">

                          @Model.CompanyName

                        </td>
                    </tr>
                    <tr>
                        <td class="text_w" align="center">开户银行</td>
                        <td colspan="5">
                            @Model.Bank

                        </td>
                    </tr>
                    <tr>
                        <td class="text_w" align="center">账号 </td>
                        <td colspan="5">
                            @Model.AccountNo
                        </td>
                    </tr>

                    <tr>

                        <td colspan="1" class="text_w" align="center">申请金额</td>
                        <td colspan="5">
                            @Model.Due

                        </td>
                    </tr>

                    <tr class="printArea_disable">
                        <td class="text_w" align="center">归属公司 <a style="color:red;position:relative; top:3px">*</a></td>
                        <td colspan="5">
                            @(Model.PayCompany.IsEmpty() ? "深圳市汇盈咨询服务有限公司" : Model.PayCompany)

                        </td>
                    </tr>

                    <tr class="printArea_disable">
                        <td class="text_w" align="center">备注 </td>
                        <td colspan="5">
                            @Model.Remark
                        </td>
                    </tr>
                    <tr>
                        <td class="text_w" align="center">06.主席终审意见</td>
                        <td colspan="5">

                           
                        </td>

                    </tr>
                    <tr>
                        <td rowspan="2" class="text_w" align="center">07.会计确认返佣</td>

                        <td class="text_w" align="center">实付中介费</td>
                        <td colspan="2">

                            <input type="text" id="Intermediary" name="Intermediary" class=" in_c1 validate[custom[number]] " style="width:98%" value="@Model.Intermediary" />
                        </td>
                        <td class="text_w" align="center">实际返佣时</td>
                        <td colspan="2">

                            <input type="text" id="RebateTime" name="RebateTime" class=" in_c1 " style="width:98%" value="@Model.RebateTime" />
                        </td>
                    </tr>
                    <tr>
                        <td class="text_w" align="center">会计备注</td>
                        <td colspan="5">

                            <input type="text" id="AccountRemark" name="AccountRemark" class=" in_c1 " style="width:98%" value="@Model.AccountRemark" />
                        </td>

                    </tr>
                    <tr>
                        <td class="text_w" align="center">08.财务确认</td>
                        <td colspan="5"></td>

                    </tr>
                  </table>
            }


        </div>
    </div>

    <script src=@Url.Content("/Scripts/jquery.form.js") type="text/javascript"></script>
    <script src=@Url.Content("/Scripts/FCDB.form.js?v=20170821") type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#frm").validationEngine({ promptPosition: "topLeft" });
            $("#FormDate").kendoDatePicker({
                format: "yyyy-MM-dd",
                value: new Date()
            });
            $("#AchievementTime").kendoDatePicker({
                format: "yyyy-MM-01",
                value: new Date()
            });

            $("#ChargingDate").kendoDatePicker({
                format: "yyyy-MM-dd",

            });
            $("#RebateTime").kendoDatePicker({
                format: "yyyy-MM-dd",

            });
            $("#InvoiceType").change(function () {
                CalRate();
            });
            $("#GuaranteeType").change(function () {
                showDL();
            });

            $("#BillType").val("@Model.Amount");
            $("#ContractType").val("@Model.Amount");
            var kendo = $("#FormDate").data("kendoDatePicker");
            var formStatus = $("#hStatus").val();

            var ProccessActiveContainerList = $(".ProccessActiveContainer");
            if (ProccessActiveContainerList.length > 0) {
                $.each(ProccessActiveContainerList, function (i, item) {
                    var divId = $(item).attr("id");
                    var frmID = divId.slice(3);
                    $("#" + frmID).appendTo(item);
                    $("#" + frmID + " select").attr("disabled", "disabled");
                    $("#" + frmID + " input").attr("disabled", "disabled");
                    $("#" + frmID).show();
                });
                $(".curentContainer form select").removeAttr("disabled");
                $(".curentContainer form input").removeAttr("disabled");
            }
        });



        function Save() {
            var formStatus = $("#hStatus").val();

            var flag = $('#frm').validationEngine('validate');
            if (!flag) return false;
            var FormConditionValue = JSON.stringify(GetFormCondition());
            var options = {
                data: {
                    FormAttachement: GetFormAttachement()
                },
                success: function (data) {
                    alert("表单保存成功");
                    window.close();
                }
            };
            $("#frm").ajaxSubmit(options);

        }
        function SaveAsDraft() {
            var flag = $('#frm').validationEngine('validate');
            var options = {
                data: { FormAttachement: GetFormAttachement(), FormsRelation: GetFormsRelation() },
                success: function (data) {
                    alert("保存成功");
                    window.close();
                }
            };
            $("#hStatus").val("1");
            $("#frm").ajaxSubmit(options);
        }
        function CalRate() {
            var Amount = $("#Amount").val();
            // 合同收款
            var ContractAmount = $("#ContractAmount").val();
            var Rate = (ContractAmount * 1.0) / Amount * 100;
            $("#Rate").val(Rate.toFixed(2));

            var ActualCharge = $("#ActualCharge").val();
            var ActualRate = (ActualCharge * 1.0) / Amount * 100;
            $("#ActualRate").val(ActualRate.toFixed(2));

            // 应付佣金=合同收款-实际收费

            var PayableAmount = ContractAmount - ActualCharge;

            $("#PayableAmount").val(PayableAmount.toFixed(2));

            var ActualRate = (ActualCharge * 1.0) / Amount * 100;
            $("#ActualRate").val();

            var InvoiceType = $("#InvoiceType").val()
            // 不开发票  shui税费= 0 实付佣金= 应付拥挤
            if (InvoiceType == 0) {
                $("#showStatus").attr("style", "display:none");
                $("#Taxation").val(0);
                $("#PaidAmount").val(PayableAmount);
            }
            // 开发票  使用应付佣金计算税费= 应付佣金 * 0.1 实付佣金= 应付佣金
            if (InvoiceType == 1) {
                $("#showStatus").attr("style", "");
                $("#Taxation").val(PayableAmount * 0.1);
                $("#PaidAmount").val(PayableAmount * 0.9);
            }

            //开发票  使用合同收款 计算税费= 应付佣金 * 0.1 实付佣金= 应付佣金
            if (InvoiceType == 2) {
                $("#showStatus").attr("style", "");
                $("#Taxation").val(ContractAmount * 0.1);
                $("#PaidAmount").val(PayableAmount - ContractAmount * 0.1);
            }

        }

        function showDL() {
            if ($("#GuaranteeType ").val() == "一般案件") {
                $(".showBX").attr("style", "display:none");
                $(".showLB").attr("style", "display:none");
            }
            if ($("#GuaranteeType ").val() == "联保案件") {
                $(".showBX").attr("style", "display:none");
                $(".showLB").attr("style", "");
            }
            if ($("#GuaranteeType ").val() == "保险案件") {
                $(".showBX").attr("style", "");
                $(".showLB").attr("style", "display:none");
            }
        }

        function addUsers() {
            var url = '@Url.Action("EmployeeSelect", "Employee")';
            OpenSelectUserPop(url, RefreshValue);
        }
        function RefreshValue(selectPostList) {
            if (selectPostList != null || selectPostList != undefined) {
                var strNames = "";
                var strUserIDs = "";
                $.each(selectPostList, function (i, val) {
                    strNames = val.Name;
                    strUserIDs = val.UserID;
                    $("#ShowSalesman").val(strNames);
                    $("#Salesman").val(strUserIDs);
                });
            }
        }
    </script>


